/**
 * Created by NMTua on 2015/9/18.
 */
/**
 * 提示框
 * @param msg       提示文本
 * @param position  垂直位置
 * @param callback  关闭后的回调
 */
com.toast = function(msg, position, callback){
    //未检测到layer插件
    if(typeof layer == 'undefined'){
        alert($.trim(msg));
        return;
    }
    var layerId;
    var params = {
        type: 0,
        content: $.trim(msg),
        time: 2,
        style: 'color: #fff; background: RGBA(0, 0, 0, 0.8); border: 0; text-align: center;',
        shade: false,
        success: function(s){
            $(s).one('click', function(){
                layer.close(layerId);
            })
        },
        end: function(){
            if(callback){
                callback(layerId);
            }
        }
    };
    if(typeof position == 'number'){
        params.fixed = false;
        params.top = position;
    }
    //兼容俩参数
    if(typeof position == 'function'){
        callback = position;
    }
    //run
    layerId = layer.open(params);
};